<?php

namespace Modules\Custessa\Helpers;

use CUrl;

class Url {
	/**
	 * Get URL for specific action.
	 *
	 * @param string $action    Action name or php script file name.
	 * @param array  $params    Key/value parameters array to be set as URL arguments.
	 */
	static public function to(string $action, array $params = []): string {
		if (substr($action, -4) !== '.php') {
			$params['action'] = $action;
			$action = 'zabbix.php';
		}

		$url = new CUrl($action);
		array_map([$url, 'setArgument'], array_keys($params), $params);

		return $url->getUrl();
	}
}
